﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Xml.Linq;
using System.Xml;
using System.IO;


namespace BYServer.Config
{
    public class YServerConfig
    {
        public static string PathConfig = "";

        /// <summary>
        /// Cho Phep 1 IP có nhieu Ket noi den Server
        /// </summary>
        public bool AllowMutipleConnection { get; set; }
        public int MaxQueue { get; set; }
        public IPAddress IPServer {get;set;}
        public int Port {get;set;}
        public int Port_Machine { get; set; }
        public int Table_ID { get; set; }
        public string PATH_CARDS { get; set; }
        public string PATH_SCRIPTS { get; set; }
        public string PATH_TXT_TEST { get; set; }
        public string PATH_TXT_LOG {get;set; }
        public YServerConfig()
        {
            LoadXMLConfig();
        }
        void LoadXMLConfig()
        {
            XDocument xml = XDocument.Load(PathConfig, LoadOptions.PreserveWhitespace);
            IPServer = IPAddress.Parse(xml.Root.Element("IPSERVER").Value);
            Port = int.Parse(xml.Root.Element("PORT").Value);
            AllowMutipleConnection = bool.Parse(xml.Root.Element("MULTICONNECTION").Value);
            MaxQueue = int.Parse(xml.Root.Element("MAXCONNECTION").Value);
            Port_Machine = int.Parse(xml.Root.Element("PORT_MANAGER").Value);
            Table_ID = int.Parse(xml.Root.Element("TABLE_ID").Value);
            
            PATH_CARDS = xml.Root.Element("PATH_CARDS").Value;
            PATH_SCRIPTS = xml.Root.Element("PATH_SCRIPTS").Value;
            PATH_TXT_TEST = xml.Root.Element("PATH_TXT_TEST").Value;
            PATH_TXT_LOG = xml.Root.Element("PATH_TXT_LOG").Value;
        }
    }
}
